import http from '@/utils/http'

const BASE_URL = '/cakerun/shopInfo'

export interface ShopInfoResp {
  id: string
  shopId: string
  accountId: string
  cityId: string
  cityName: string
  poiName: string
  address: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  enable: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface ShopInfoDetailResp {
  id: string
  shopId: string
  accountId: string
  cityId: string
  cityName: string
  poiName: string
  address: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  enable: string
  createUserString: string
  updateUserString: string
}
export interface ShopInfoQuery {
  sort?: Array<string>
  enable?: boolean
  accountId?: string[]
}
export interface ShopInfoPageQuery extends ShopInfoQuery, PageQuery {}

/** @desc 查询店铺信息列表 */
export function listShopInfo(query: ShopInfoPageQuery) {
  return http.get<PageRes<ShopInfoResp[]>>(BASE_URL, query)
}

/** @desc 查询店铺信息详情 */
export function getShopInfo(id: string) {
  return http.get<ShopInfoDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增店铺信息 */
export function addShopInfo(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改店铺信息 */
export function updateShopInfo(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除店铺信息 */
export function deleteShopInfo(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出店铺信息 */
export function exportShopInfo(query: ShopInfoQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
/** @desc 查询所有品牌信息列表 */
export function listAllShop(query: ShopInfoQuery) {
  return http.get<ShopInfoResp[]>(`${BASE_URL}/list`, query)
}
